package com.example.yk_fx.base;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.databinding.DataBindingUtil;
import androidx.databinding.ViewDataBinding;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider;

import com.example.yk_fx.R;

public abstract class BaseFragment<VDB extends ViewDataBinding,VM extends BaseViewModel> extends Fragment {
    protected VDB vdb;
    protected VM vm;
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        vdb = DataBindingUtil.inflate(inflater,bindLayout(),container,false);
        vm = new ViewModelProvider(this).get(getViewModel());
        initView();
        initData();
        return vdb.getRoot();
    }
    protected abstract int bindLayout();
    protected abstract Class<VM> getViewModel();
    protected abstract void initView();
    protected abstract void initData();
}
